from functools import reduce


# map 用的函数
def f1(num):
    return num * num


# reduce用的函数
def f2(num1, num2):
    return num1 + num2


# map reduce
if __name__ == '__main__':
    paras = [1, 2, 3, 4]

    # map 做参数处理
    result1 = map(f1, paras)
    print(list(result1))

    # reduce 做求和
    result2 = reduce(f2, paras)
    print(result2)
